<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The AQUA Project, Glasgow University, 1993-1998

\section{Common subexpression}
-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns   #-}</span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.CSE</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseProgram"><span class="hs-identifier">cseProgram</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseOneExpr"><span class="hs-identifier">cseOneExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html"><span class="hs-identifier">GHC.Core.Subst</span></a></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier">Var</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier">mkInScopeSet</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#idType"><span class="hs-identifier">idType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#idHasRules"><span class="hs-identifier">idHasRules</span></a></span><span>
</span><span id="line-22"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier">idInlineActivation</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#setInlineActivation"><span class="hs-identifier">setInlineActivation</span></a></span><span>
</span><span id="line-23"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#zapIdOccInfo"><span class="hs-identifier">zapIdOccInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#zapIdUsageInfo"><span class="hs-identifier">zapIdUsageInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier">idInlinePragma</span></a></span><span>
</span><span id="line-24"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier">isJoinId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier">isJoinId_maybe</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#mkAltExpr"><span class="hs-identifier">mkAltExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#eqExpr"><span class="hs-identifier">eqExpr</span></a></span><span>
</span><span id="line-26"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprIsTickedString"><span class="hs-identifier">exprIsTickedString</span></a></span><span>
</span><span id="line-27"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#stripTicksE"><span class="hs-identifier">stripTicksE</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#stripTicksT"><span class="hs-identifier">stripTicksT</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier">mkTicks</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier">exprFreeVars</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#tyConAppArgs"><span class="hs-identifier">tyConAppArgs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Map.html"><span class="hs-identifier">GHC.Core.Map</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier">filterOut</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-identifier">equalLength</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier">debugIsOn</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-comment">{-
                        Simple common sub-expression
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we see
        x1 = C a b
        x2 = C x1 b
we build up a reverse mapping:   C a b  -&gt; x1
                                 C x1 b -&gt; x2
and apply that to the rest of the program.

When we then see
        y1 = C a b
        y2 = C y1 b
we replace the C a b with x1.  But then we *dont* want to
add   x1 -&gt; y1  to the mapping.  Rather, we want the reverse, y1 -&gt; x1
so that a subsequent binding
        y2 = C y1 b
will get transformed to C x1 b, and then to x2.

So we carry an extra var-&gt;var substitution which we apply *before* looking up in the
reverse mapping.


Note [Shadowing]
~~~~~~~~~~~~~~~~
We have to be careful about shadowing.
For example, consider
        f = \x -&gt; let y = x+x in
                      h = \x -&gt; x+x
                  in ...

Here we must *not* do CSE on the inner x+x!  The simplifier used to guarantee no
shadowing, but it doesn't any more (it proved too hard), so we clone as we go.
We can simply add clones to the substitution already described.


Note [CSE for bindings]
~~~~~~~~~~~~~~~~~~~~~~~
Let-bindings have two cases, implemented by addBinding.

* SUBSTITUTE: applies when the RHS is a variable

     let x = y in ...(h x)....

  Here we want to extend the /substitution/ with x -&gt; y, so that the
  (h x) in the body might CSE with an enclosing (let v = h y in ...).
  NB: the substitution maps InIds, so we extend the substitution with
      a binding for the original InId 'x'

  How can we have a variable on the RHS? Doesn't the simplifier inline them?

    - First, the original RHS might have been (g z) which has CSE'd
      with an enclosing (let y = g z in ...).  This is super-important.
      See #5996:
         x1 = C a b
         x2 = C x1 b
         y1 = C a b
         y2 = C y1 b
      Here we CSE y1's rhs to 'x1', and then we must add (y1-&gt;x1) to
      the substitution so that we can CSE the binding for y2.

    - Second, we use addBinding for case expression scrutinees too;
      see Note [CSE for case expressions]

* EXTEND THE REVERSE MAPPING: applies in all other cases

     let x = h y in ...(h y)...

  Here we want to extend the /reverse mapping (cs_map)/ so that
  we CSE the (h y) call to x.

  Note that we use EXTEND even for a trivial expression, provided it
  is not a variable or literal. In particular this /includes/ type
  applications. This can be important (#13156); e.g.
     case f @ Int of { r1 -&gt;
     case f @ Int of { r2 -&gt; ...
  Here we want to common-up the two uses of (f @ Int) so we can
  remove one of the case expressions.

  See also Note [Corner case for case expressions] for another
  reason not to use SUBSTITUTE for all trivial expressions.

Notice that
  - The SUBSTITUTE situation extends the substitution (cs_subst)
  - The EXTEND situation extends the reverse mapping (cs_map)

Notice also that in the SUBSTITUTE case we leave behind a binding
  x = y
even though we /also/ carry a substitution x -&gt; y.  Can we just drop
the binding instead?  Well, not at top level! See Note [Top level and
postInlineUnconditionally] in GHC.Core.Opt.Simplify.Utils; and in any
case CSE applies only to the /bindings/ of the program, and we leave
it to the simplifier to propate effects to the RULES. Finally, it
doesn't seem worth the effort to discard the nested bindings because
the simplifier will do it next.

Note [CSE for case expressions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  case scrut_expr of x { ...alts... }
This is very like a strict let-binding
  let !x = scrut_expr in ...
So we use (addBinding x scrut_expr) to process scrut_expr and x, and as a
result all the stuff under Note [CSE for bindings] applies directly.

For example:

* Trivial scrutinee
     f = \x -&gt; case x of wild {
                 (a:as) -&gt; case a of wild1 {
                             (p,q) -&gt; ...(wild1:as)...

  Here, (wild1:as) is morally the same as (a:as) and hence equal to
  wild. But that's not quite obvious.  In the rest of the compiler we
  want to keep it as (wild1:as), but for CSE purpose that's a bad
  idea.

  By using addBinding we add the binding (wild1 -&gt; a) to the substitution,
  which does exactly the right thing.

  (Notice this is exactly backwards to what the simplifier does, which
  is to try to replaces uses of 'a' with uses of 'wild1'.)

  This is the main reason that addBinding is called with a trivial rhs.

* Non-trivial scrutinee
     case (f x) of y { pat -&gt; ...let z = f x in ... }

  By using addBinding we'll add (f x :-&gt; y) to the cs_map, and
  thereby CSE the inner (f x) to y.

Note [CSE for INLINE and NOINLINE]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are some subtle interactions of CSE with functions that the user
has marked as INLINE or NOINLINE. (Examples from Roman Leshchinskiy.)
Consider

        yes :: Int  {-# NOINLINE yes #-}
        yes = undefined

        no :: Int   {-# NOINLINE no #-}
        no = undefined

        foo :: Int -&gt; Int -&gt; Int  {-# NOINLINE foo #-}
        foo m n = n

        {-# RULES &quot;foo/no&quot; foo no = id #-}

        bar :: Int -&gt; Int
        bar = foo yes

We do not expect the rule to fire.  But if we do CSE, then we risk
getting yes=no, and the rule does fire.  Actually, it won't because
NOINLINE means that 'yes' will never be inlined, not even if we have
yes=no.  So that's fine (now; perhaps in the olden days, yes=no would
have substituted even if 'yes' was NOINLINE).

But we do need to take care.  Consider

        {-# NOINLINE bar #-}
        bar = &lt;rhs&gt;     -- Same rhs as foo

        foo = &lt;rhs&gt;

If CSE produces
        foo = bar
then foo will never be inlined to &lt;rhs&gt; (when it should be, if &lt;rhs&gt;
is small).  The conclusion here is this:

   We should not add
       &lt;rhs&gt; :-&gt; bar
  to the CSEnv if 'bar' has any constraints on when it can inline;
  that is, if its 'activation' not always active.  Otherwise we
  might replace &lt;rhs&gt; by 'bar', and then later be unable to see that it
  really was &lt;rhs&gt;.

An except to the rule is when the INLINE pragma is not from the user, e.g. from
WorkWrap (see Note [Wrapper activation]). We can tell because noUserInlineSpec
is then true.

Note that we do not (currently) do CSE on the unfolding stored inside
an Id, even if it is a 'stable' unfolding.  That means that when an
unfolding happens, it is always faithful to what the stable unfolding
originally was.

Note [CSE for stable unfoldings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   {-# Unf = Stable (\pq. build blah) #-}
   foo = x

Here 'foo' has a stable unfolding, but its (optimised) RHS is trivial.
(Turns out that this actually happens for the enumFromTo method of
the Integer instance of Enum in GHC.Enum.)  Suppose moreover that foo's
stable unfolding originates from an INLINE or INLINEABLE pragma on foo.
Then we obviously do NOT want to extend the substitution with (foo-&gt;x),
because we promised to inline foo as what the user wrote.  See similar Note
[Stable unfoldings and postInlineUnconditionally] in GHC.Core.Opt.Simplify.Utils.

Nor do we want to change the reverse mapping. Suppose we have

   {-# Unf = Stable (\pq. build blah) #-}
   foo = &lt;expr&gt;
   bar = &lt;expr&gt;

There could conceivably be merit in rewriting the RHS of bar:
   bar = foo
but now bar's inlining behaviour will change, and importing
modules might see that.  So it seems dodgy and we don't do it.

Stable unfoldings are also created during worker/wrapper when we decide
that a function's definition is so small that it should always inline.
In this case we still want to do CSE (#13340). Hence the use of
isAnyInlinePragma rather than isStableUnfolding.

Note [Corner case for case expressions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is another reason that we do not use SUBSTITUTE for
all trivial expressions. Consider
   case x |&gt; co of (y::Array# Int) { ... }

We do not want to extend the substitution with (y -&gt; x |&gt; co); since y
is of unlifted type, this would destroy the let/app invariant if (x |&gt;
co) was not ok-for-speculation.

But surely (x |&gt; co) is ok-for-speculation, because it's a trivial
expression, and x's type is also unlifted, presumably.  Well, maybe
not if you are using unsafe casts.  I actually found a case where we
had
   (x :: HValue) |&gt; (UnsafeCo :: HValue ~ Array# Int)

Note [CSE for join points?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
We must not be naive about join points in CSE:
   join j = e in
   if b then jump j else 1 + e
The expression (1 + jump j) is not good (see Note [Invariants on join points] in
GHC.Core). This seems to come up quite seldom, but it happens (first seen
compiling ppHtml in Haddock.Backends.Xhtml).

We could try and be careful by tracking which join points are still valid at
each subexpression, but since join points aren't allocated or shared, there's
less to gain by trying to CSE them. (#13219)

Note [Look inside join-point binders]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another way how CSE for join points is tricky is

  let join foo x = (x, 42)
      join bar x = (x, 42)
  in &#8230; jump foo 1 &#8230; jump bar 2 &#8230;

naively, CSE would turn this into

  let join foo x = (x, 42)
      join bar = foo
  in &#8230; jump foo 1 &#8230; jump bar 2 &#8230;

but now bar is a join point that claims arity one, but its right-hand side
is not a lambda, breaking the join-point invariant (this was #15002).

So `cse_bind` must zoom past the lambdas of a join point (using
`collectNBinders`) and resume searching for CSE opportunities only in
the body of the join point.

Note [CSE for recursive bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  f = \x ... f....
  g = \y ... g ...
where the &quot;...&quot; are identical.  Could we CSE them?  In full generality
with mutual recursion it's quite hard; but for self-recursive bindings
(which are very common) it's rather easy:

* Maintain a separate cs_rec_map, that maps
      (\f. (\x. ...f...) ) -&gt; f
  Note the \f in the domain of the mapping!

* When we come across the binding for 'g', look up (\g. (\y. ...g...))
  Bingo we get a hit.  So we can replace the 'g' binding with
     g = f

We can't use cs_map for this, because the key isn't an expression of
the program; it's a kind of synthetic key for recursive bindings.


************************************************************************
*                                                                      *
\section{Common subexpression}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-329"></span><span>
</span><span id="line-330"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseProgram"><span class="hs-identifier hs-type">cseProgram</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span>
</span><span id="line-331"></span><span id="cseProgram"><span class="annot"><span class="annottext">cseProgram :: CoreProgram -&gt; CoreProgram
</span><a href="GHC.Core.Opt.CSE.html#cseProgram"><span class="hs-identifier hs-var hs-var">cseProgram</span></a></span></span><span> </span><span id="local-6989586621680961195"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680961195"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CSEnv, CoreProgram) -&gt; CoreProgram
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CSEnv -&gt; CoreBind -&gt; (CSEnv, CoreBind))
-&gt; CSEnv -&gt; CoreProgram -&gt; (CSEnv, CoreProgram)
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TopLevelFlag -&gt; CSEnv -&gt; CoreBind -&gt; (CSEnv, CoreBind)
</span><a href="GHC.Core.Opt.CSE.html#cseBind"><span class="hs-identifier hs-var">cseBind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="GHC.Core.Opt.CSE.html#emptyCSEnv"><span class="hs-identifier hs-var">emptyCSEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680961195"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseBind"><span class="hs-identifier hs-type">cseBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-334"></span><span id="cseBind"><span class="annot"><span class="annottext">cseBind :: TopLevelFlag -&gt; CSEnv -&gt; CoreBind -&gt; (CSEnv, CoreBind)
</span><a href="GHC.Core.Opt.CSE.html#cseBind"><span class="hs-identifier hs-var hs-var">cseBind</span></a></span></span><span> </span><span id="local-6989586621680961191"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961191"><span class="hs-identifier hs-var">toplevel</span></a></span></span><span> </span><span id="local-6989586621680961190"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961190"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680961188"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961188"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680961187"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961187"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-335"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961186"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961185"><span class="hs-identifier hs-var">b2</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961184"><span class="hs-identifier hs-var">e2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-336"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-337"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961183"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961183"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961182"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961182"><span class="hs-identifier hs-var">b1</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinder"><span class="hs-identifier hs-var">addBinder</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961190"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961188"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-338"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961186"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961186"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961185"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961185"><span class="hs-identifier hs-var">b2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961184"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961184"><span class="hs-identifier hs-var">e2</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; CSEnv
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; CoreBndr
-&gt; (CSEnv, (CoreBndr, Expr CoreBndr))
</span><a href="GHC.Core.Opt.CSE.html#cse_bind"><span class="hs-identifier hs-var">cse_bind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961191"><span class="hs-identifier hs-var">toplevel</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961183"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961188"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961187"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961182"><span class="hs-identifier hs-var">b1</span></a></span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseBind"><span class="hs-identifier hs-var">cseBind</span></a></span><span> </span><span id="local-6989586621680961179"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961179"><span class="hs-identifier hs-var">toplevel</span></a></span></span><span> </span><span id="local-6989586621680961178"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961178"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span id="local-6989586621680961176"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961176"><span class="hs-identifier hs-var">in_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961175"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961175"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-341"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CSE.html#noCSE"><span class="hs-identifier hs-var">noCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961176"><span class="hs-identifier hs-var">in_id</span></a></span><span>
</span><span id="line-342"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961173"><span class="hs-identifier hs-var">env1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961171"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-343"></span><span>
</span><span id="line-344"></span><span>  </span><span class="hs-comment">-- See Note [CSE for recursive bindings]</span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680961170"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961170"><span class="hs-identifier hs-var">previous</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#lookupCSRecEnv"><span class="hs-identifier hs-var">lookupCSRecEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961178"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961168"><span class="hs-identifier hs-var">rhs''</span></a></span><span>
</span><span id="line-346"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680961167"><span class="annot"><span class="annottext">previous' :: Expr CoreBndr
</span><a href="#local-6989586621680961167"><span class="hs-identifier hs-var hs-var">previous'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr] -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier hs-var">mkTicks</span></a></span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680961166"><span class="hs-identifier hs-var">ticks</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961170"><span class="hs-identifier hs-var">previous</span></a></span><span>
</span><span id="line-347"></span><span>        </span><span id="local-6989586621680961165"><span class="annot"><span class="annottext">out_id' :: CoreBndr
</span><a href="#local-6989586621680961165"><span class="hs-identifier hs-var hs-var">out_id'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#delayInlining"><span class="hs-identifier hs-var">delayInlining</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961179"><span class="hs-identifier hs-var">toplevel</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span><span>
</span><span id="line-348"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- We have a hit in the recursive-binding cache</span><span>
</span><span id="line-349"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSSubst"><span class="hs-identifier hs-var">extendCSSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961173"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961176"><span class="hs-identifier hs-var">in_id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961167"><span class="hs-identifier hs-var">previous'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961165"><span class="hs-identifier hs-var">out_id'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961167"><span class="hs-identifier hs-var">previous'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-352"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSRecEnv"><span class="hs-identifier hs-var">extendCSRecEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961173"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961168"><span class="hs-identifier hs-var">rhs''</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
forall {b}. Expr b
</span><a href="#local-6989586621680961161"><span class="hs-identifier hs-var">id_expr'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961160"><span class="hs-identifier hs-var">zapped_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961171"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-353"></span><span>
</span><span id="line-354"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-355"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961173"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961173"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680961172"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addRecBinders"><span class="hs-identifier hs-var">addRecBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961178"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961176"><span class="hs-identifier hs-var">in_id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-356"></span><span>    </span><span id="local-6989586621680961171"><span class="annot"><span class="annottext">rhs' :: Expr CoreBndr
</span><a href="#local-6989586621680961171"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961173"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961175"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-357"></span><span>    </span><span id="local-6989586621680961168"><span class="annot"><span class="annottext">rhs'' :: Expr CoreBndr
</span><a href="#local-6989586621680961168"><span class="hs-identifier hs-var hs-var">rhs''</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool) -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. (Tickish CoreBndr -&gt; Bool) -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.Utils.html#stripTicksE"><span class="hs-identifier hs-var">stripTicksE</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961171"><span class="hs-identifier hs-var">rhs'</span></a></span><span>
</span><span id="line-358"></span><span>    </span><span id="local-6989586621680961166"><span class="annot"><span class="annottext">ticks :: [Tickish CoreBndr]
</span><a href="#local-6989586621680961166"><span class="hs-identifier hs-var hs-var">ticks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool) -&gt; Expr CoreBndr -&gt; [Tickish CoreBndr]
forall b.
(Tickish CoreBndr -&gt; Bool) -&gt; Expr b -&gt; [Tickish CoreBndr]
</span><a href="GHC.Core.Utils.html#stripTicksT"><span class="hs-identifier hs-var">stripTicksT</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961171"><span class="hs-identifier hs-var">rhs'</span></a></span><span>
</span><span id="line-359"></span><span>    </span><span id="local-6989586621680961161"><span class="annot"><span class="annottext">id_expr' :: Expr b
</span><a href="#local-6989586621680961161"><span class="hs-identifier hs-var hs-var">id_expr'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr b
forall b. CoreBndr -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span><span>
</span><span id="line-360"></span><span>    </span><span id="local-6989586621680961160"><span class="annot"><span class="annottext">zapped_id :: CoreBndr
</span><a href="#local-6989586621680961160"><span class="hs-identifier hs-var hs-var">zapped_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#zapIdUsageInfo"><span class="hs-identifier hs-var">zapIdUsageInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961172"><span class="hs-identifier hs-var">out_id</span></a></span><span>
</span><span id="line-361"></span><span>
</span><span id="line-362"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseBind"><span class="hs-identifier hs-var">cseBind</span></a></span><span> </span><span id="local-6989586621680961155"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961155"><span class="hs-identifier hs-var">toplevel</span></a></span></span><span> </span><span id="local-6989586621680961154"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961154"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680961153"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680961153"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-363"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961152"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680961151"><span class="hs-identifier hs-var">pairs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-364"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-365"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961150"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961150"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961149"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961149"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addRecBinders"><span class="hs-identifier hs-var">addRecBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961154"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((CoreBndr, Expr CoreBndr) -&gt; CoreBndr)
-&gt; [(CoreBndr, Expr CoreBndr)] -&gt; [CoreBndr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, Expr CoreBndr) -&gt; CoreBndr
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680961153"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-366"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961152"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961152"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961151"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680961151"><span class="hs-identifier hs-var">pairs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CSEnv
 -&gt; ((CoreBndr, Expr CoreBndr), CoreBndr)
 -&gt; (CSEnv, (CoreBndr, Expr CoreBndr)))
-&gt; CSEnv
-&gt; [((CoreBndr, Expr CoreBndr), CoreBndr)]
-&gt; (CSEnv, [(CoreBndr, Expr CoreBndr)])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
-&gt; ((CoreBndr, Expr CoreBndr), CoreBndr)
-&gt; (CSEnv, (CoreBndr, Expr CoreBndr))
</span><a href="#local-6989586621680961147"><span class="hs-identifier hs-var">do_one</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961150"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
-&gt; [CoreBndr] -&gt; [((CoreBndr, Expr CoreBndr), CoreBndr)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680961153"><span class="hs-identifier hs-var">pairs</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961149"><span class="hs-identifier hs-var">bndrs1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span>    </span><span id="local-6989586621680961147"><span class="annot"><span class="annottext">do_one :: CSEnv
-&gt; ((CoreBndr, Expr CoreBndr), CoreBndr)
-&gt; (CSEnv, (CoreBndr, Expr CoreBndr))
</span><a href="#local-6989586621680961147"><span class="hs-identifier hs-var hs-var">do_one</span></a></span></span><span> </span><span id="local-6989586621680961146"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961146"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961145"><span class="annot"><span class="annottext">(CoreBndr, Expr CoreBndr)
</span><a href="#local-6989586621680961145"><span class="hs-identifier hs-var">pr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961144"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961144"><span class="hs-identifier hs-var">b1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; CSEnv
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; CoreBndr
-&gt; (CSEnv, (CoreBndr, Expr CoreBndr))
</span><a href="GHC.Core.Opt.CSE.html#cse_bind"><span class="hs-identifier hs-var">cse_bind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961155"><span class="hs-identifier hs-var">toplevel</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961146"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, Expr CoreBndr)
</span><a href="#local-6989586621680961145"><span class="hs-identifier hs-var">pr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961144"><span class="hs-identifier hs-var">b1</span></a></span><span>
</span><span id="line-369"></span><span>
</span><span id="line-370"></span><span class="hs-comment">-- | Given a binding of @in_id@ to @in_rhs@, and a fresh name to refer</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- to @in_id@ (@out_id@, created from addBinder or addRecBinders),</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- first try to CSE @in_rhs@, and then add the resulting (possibly CSE'd)</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- binding to the 'CSEnv', so that we attempt to CSE any expressions</span><span>
</span><span id="line-374"></span><span class="hs-comment">-- which are equal to @out_rhs@.</span><span>
</span><span id="line-375"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cse_bind"><span class="hs-identifier hs-type">cse_bind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-376"></span><span id="cse_bind"><span class="annot"><span class="annottext">cse_bind :: TopLevelFlag
-&gt; CSEnv
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; CoreBndr
-&gt; (CSEnv, (CoreBndr, Expr CoreBndr))
</span><a href="GHC.Core.Opt.CSE.html#cse_bind"><span class="hs-identifier hs-var hs-var">cse_bind</span></a></span></span><span> </span><span id="local-6989586621680961139"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961139"><span class="hs-identifier hs-var">toplevel</span></a></span></span><span> </span><span id="local-6989586621680961138"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961138"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961137"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961137"><span class="hs-identifier hs-var">in_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961136"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961136"><span class="hs-identifier hs-var">in_rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680961135"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961135"><span class="hs-identifier hs-var">out_id</span></a></span></span><span>
</span><span id="line-377"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isTopLevel"><span class="hs-identifier hs-var">isTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961139"><span class="hs-identifier hs-var">toplevel</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsTickedString"><span class="hs-identifier hs-var">exprIsTickedString</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961136"><span class="hs-identifier hs-var">in_rhs</span></a></span><span>
</span><span id="line-378"></span><span>      </span><span class="hs-comment">-- See Note [Take care with literal strings]</span><span>
</span><span id="line-379"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961133"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961132"><span class="hs-identifier hs-var">out_id'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961136"><span class="hs-identifier hs-var">in_rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680961131"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680961131"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Maybe JoinArity
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961137"><span class="hs-identifier hs-var">in_id</span></a></span><span>
</span><span id="line-382"></span><span>      </span><span class="hs-comment">-- See Note [Look inside join-point binders]</span><span>
</span><span id="line-383"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961130"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961130"><span class="hs-identifier hs-var">params</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961129"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961129"><span class="hs-identifier hs-var">in_body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Expr CoreBndr -&gt; ([CoreBndr], Expr CoreBndr)
forall b. JoinArity -&gt; Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectNBinders"><span class="hs-identifier hs-var">collectNBinders</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680961131"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961136"><span class="hs-identifier hs-var">in_rhs</span></a></span><span>
</span><span id="line-384"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680961127"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961127"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961126"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961126"><span class="hs-identifier hs-var">params'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addBinders"><span class="hs-identifier hs-var">addBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961138"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961130"><span class="hs-identifier hs-var">params</span></a></span><span>
</span><span id="line-385"></span><span>        </span><span id="local-6989586621680961124"><span class="annot"><span class="annottext">out_body :: Expr CoreBndr
</span><a href="#local-6989586621680961124"><span class="hs-identifier hs-var hs-var">out_body</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var">tryForCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961127"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961129"><span class="hs-identifier hs-var">in_body</span></a></span><span>
</span><span id="line-386"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961138"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961135"><span class="hs-identifier hs-var">out_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961126"><span class="hs-identifier hs-var">params'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961124"><span class="hs-identifier hs-var">out_body</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-387"></span><span>
</span><span id="line-388"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-389"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961133"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961121"><span class="hs-identifier hs-var">out_id''</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961120"><span class="hs-identifier hs-var">out_rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-390"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-391"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961133"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961133"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961132"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961132"><span class="hs-identifier hs-var">out_id'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinding"><span class="hs-identifier hs-var">addBinding</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961138"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961137"><span class="hs-identifier hs-var">in_id</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961135"><span class="hs-identifier hs-var">out_id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961120"><span class="hs-identifier hs-var">out_rhs</span></a></span><span>
</span><span id="line-392"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961118"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680961118"><span class="hs-identifier hs-var">cse_done</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961120"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961120"><span class="hs-identifier hs-var">out_rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; (Bool, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#try_for_cse"><span class="hs-identifier hs-var">try_for_cse</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961138"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961136"><span class="hs-identifier hs-var">in_rhs</span></a></span><span>
</span><span id="line-393"></span><span>    </span><span id="local-6989586621680961121"><span class="annot"><span class="annottext">out_id'' :: CoreBndr
</span><a href="#local-6989586621680961121"><span class="hs-identifier hs-var hs-var">out_id''</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680961118"><span class="hs-identifier hs-var">cse_done</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#delayInlining"><span class="hs-identifier hs-var">delayInlining</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961139"><span class="hs-identifier hs-var">toplevel</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961132"><span class="hs-identifier hs-var">out_id'</span></a></span><span>
</span><span id="line-394"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961132"><span class="hs-identifier hs-var">out_id'</span></a></span><span>
</span><span id="line-395"></span><span>
</span><span id="line-396"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#delayInlining"><span class="hs-identifier hs-type">delayInlining</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-397"></span><span class="hs-comment">-- Add a NOINLINE[2] if the Id doesn't have an INLNE pragma already</span><span>
</span><span id="line-398"></span><span class="hs-comment">-- See Note [Delay inlining after CSE]</span><span>
</span><span id="line-399"></span><span id="delayInlining"><span class="annot"><span class="annottext">delayInlining :: TopLevelFlag -&gt; CoreBndr -&gt; CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#delayInlining"><span class="hs-identifier hs-var hs-var">delayInlining</span></a></span></span><span> </span><span id="local-6989586621680961116"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961116"><span class="hs-identifier hs-var">top_lvl</span></a></span></span><span> </span><span id="local-6989586621680961115"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961115"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-400"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isTopLevel"><span class="hs-identifier hs-var">isTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680961116"><span class="hs-identifier hs-var">top_lvl</span></a></span><span>
</span><span id="line-401"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="GHC.Types.Basic.html#isAlwaysActive"><span class="hs-identifier hs-var">isAlwaysActive</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Activation
</span><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier hs-var">idInlineActivation</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961115"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-402"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#idHasRules"><span class="hs-identifier hs-var">idHasRules</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961115"><span class="hs-identifier hs-var">bndr</span></a></span><span>  </span><span class="hs-comment">-- Only if the Id has some RULES,</span><span>
</span><span id="line-403"></span><span>                     </span><span class="hs-comment">-- which might otherwise get lost</span><span>
</span><span id="line-404"></span><span>       </span><span class="hs-comment">-- These rules are probably auto-generated specialisations,</span><span>
</span><span id="line-405"></span><span>       </span><span class="hs-comment">-- since Ids with manual rules usually have manually-inserted</span><span>
</span><span id="line-406"></span><span>       </span><span class="hs-comment">-- delayed inlining anyway</span><span>
</span><span id="line-407"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961115"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Activation -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setInlineActivation"><span class="hs-operator hs-var">`setInlineActivation`</span></a></span><span> </span><span class="annot"><span class="annottext">Activation
</span><a href="GHC.Types.Basic.html#activateAfterInitial"><span class="hs-identifier hs-var">activateAfterInitial</span></a></span><span>
</span><span id="line-408"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-409"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961115"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-410"></span><span>
</span><span id="line-411"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#addBinding"><span class="hs-identifier hs-type">addBinding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span>                      </span><span class="hs-comment">-- Includes InId-&gt;OutId cloning</span><span>
</span><span id="line-412"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span>                      </span><span class="hs-comment">-- Could be a let-bound type</span><span>
</span><span id="line-413"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>           </span><span class="hs-comment">-- Processed binding</span><span>
</span><span id="line-414"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">)</span><span>             </span><span class="hs-comment">-- Final env, final bndr</span><span>
</span><span id="line-415"></span><span class="hs-comment">-- Extend the CSE env with a mapping [rhs -&gt; out-id]</span><span>
</span><span id="line-416"></span><span class="hs-comment">-- unless we can instead just substitute [in-id -&gt; rhs]</span><span>
</span><span id="line-417"></span><span class="hs-comment">--</span><span>
</span><span id="line-418"></span><span class="hs-comment">-- It's possible for the binder to be a type variable (see</span><span>
</span><span id="line-419"></span><span class="hs-comment">-- Note [Type-let] in GHC.Core), in which case we can just substitute.</span><span>
</span><span id="line-420"></span><span id="addBinding"><span class="annot"><span class="annottext">addBinding :: CSEnv -&gt; CoreBndr -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinding"><span class="hs-identifier hs-var hs-var">addBinding</span></a></span></span><span> </span><span id="local-6989586621680961111"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961111"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680961110"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961110"><span class="hs-identifier hs-var">in_id</span></a></span></span><span> </span><span id="local-6989586621680961109"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961109"><span class="hs-identifier hs-var">out_id</span></a></span></span><span> </span><span id="local-6989586621680961108"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961108"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span>
</span><span id="line-421"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961110"><span class="hs-identifier hs-var">in_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSSubst"><span class="hs-identifier hs-var">extendCSSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961111"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961110"><span class="hs-identifier hs-var">in_id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961108"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span>     </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961109"><span class="hs-identifier hs-var">out_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-422"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CSE.html#noCSE"><span class="hs-identifier hs-var">noCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961110"><span class="hs-identifier hs-var">in_id</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961111"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span>                              </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961109"><span class="hs-identifier hs-var">out_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-423"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680961105"><span class="hs-identifier hs-var">use_subst</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSSubst"><span class="hs-identifier hs-var">extendCSSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961111"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961110"><span class="hs-identifier hs-var">in_id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961108"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span>     </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961109"><span class="hs-identifier hs-var">out_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-424"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSEnv"><span class="hs-identifier hs-var">extendCSEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961111"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961108"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
forall {b}. Expr b
</span><a href="#local-6989586621680961103"><span class="hs-identifier hs-var">id_expr'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961102"><span class="hs-identifier hs-var">zapped_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-425"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-426"></span><span>    </span><span id="local-6989586621680961103"><span class="annot"><span class="annottext">id_expr' :: Expr b
</span><a href="#local-6989586621680961103"><span class="hs-identifier hs-var hs-var">id_expr'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr b
forall b. CoreBndr -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961109"><span class="hs-identifier hs-var">out_id</span></a></span><span>
</span><span id="line-427"></span><span>    </span><span id="local-6989586621680961102"><span class="annot"><span class="annottext">zapped_id :: CoreBndr
</span><a href="#local-6989586621680961102"><span class="hs-identifier hs-var hs-var">zapped_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#zapIdUsageInfo"><span class="hs-identifier hs-var">zapIdUsageInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961109"><span class="hs-identifier hs-var">out_id</span></a></span><span>
</span><span id="line-428"></span><span>       </span><span class="hs-comment">-- Putting the Id into the cs_map makes it possible that</span><span>
</span><span id="line-429"></span><span>       </span><span class="hs-comment">-- it'll become shared more than it is now, which would</span><span>
</span><span id="line-430"></span><span>       </span><span class="hs-comment">-- invalidate (the usage part of) its demand info.</span><span>
</span><span id="line-431"></span><span>       </span><span class="hs-comment">--    This caused #100218.</span><span>
</span><span id="line-432"></span><span>       </span><span class="hs-comment">-- Easiest thing is to zap the usage info; subsequently</span><span>
</span><span id="line-433"></span><span>       </span><span class="hs-comment">-- performing late demand-analysis will restore it.  Don't zap</span><span>
</span><span id="line-434"></span><span>       </span><span class="hs-comment">-- the strictness info; it's not necessary to do so, and losing</span><span>
</span><span id="line-435"></span><span>       </span><span class="hs-comment">-- it is bad for performance if you don't do late demand</span><span>
</span><span id="line-436"></span><span>       </span><span class="hs-comment">-- analysis</span><span>
</span><span id="line-437"></span><span>
</span><span id="line-438"></span><span>    </span><span class="hs-comment">-- Should we use SUBSTITUTE or EXTEND?</span><span>
</span><span id="line-439"></span><span>    </span><span class="hs-comment">-- See Note [CSE for bindings]</span><span>
</span><span id="line-440"></span><span>    </span><span id="local-6989586621680961105"><span class="annot"><span class="annottext">use_subst :: Bool
</span><a href="#local-6989586621680961105"><span class="hs-identifier hs-var hs-var">use_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961108"><span class="hs-identifier hs-var">rhs'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-441"></span><span>                   </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-442"></span><span>                   </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-443"></span><span>
</span><span id="line-444"></span><span class="hs-comment">-- | Given a binder `let x = e`, this function</span><span>
</span><span id="line-445"></span><span class="hs-comment">-- determines whether we should add `e -&gt; x` to the cs_map</span><span>
</span><span id="line-446"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#noCSE"><span class="hs-identifier hs-type">noCSE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-447"></span><span id="noCSE"><span class="annot"><span class="annottext">noCSE :: CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CSE.html#noCSE"><span class="hs-identifier hs-var hs-var">noCSE</span></a></span></span><span> </span><span id="local-6989586621680961100"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961100"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="GHC.Types.Basic.html#isAlwaysActive"><span class="hs-identifier hs-var">isAlwaysActive</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Activation
</span><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier hs-var">idInlineActivation</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961100"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-448"></span><span>            </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlineSpec -&gt; Bool
</span><a href="GHC.Types.Basic.html#noUserInlineSpec"><span class="hs-identifier hs-var">noUserInlineSpec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlinePragma -&gt; InlineSpec
</span><a href="GHC.Types.Basic.html#inlinePragmaSpec"><span class="hs-identifier hs-var">inlinePragmaSpec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; InlinePragma
</span><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier hs-var">idInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961100"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-449"></span><span>             </span><span class="hs-comment">-- See Note [CSE for INLINE and NOINLINE]</span><span>
</span><span id="line-450"></span><span>         </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">InlinePragma -&gt; Bool
</span><a href="GHC.Types.Basic.html#isAnyInlinePragma"><span class="hs-identifier hs-var">isAnyInlinePragma</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; InlinePragma
</span><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier hs-var">idInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961100"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-451"></span><span>             </span><span class="hs-comment">-- See Note [CSE for stable unfoldings]</span><span>
</span><span id="line-452"></span><span>         </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961100"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-453"></span><span>             </span><span class="hs-comment">-- See Note [CSE for join points?]</span><span>
</span><span id="line-454"></span><span>
</span><span id="line-455"></span><span>
</span><span id="line-456"></span><span class="hs-comment">{- Note [Take care with literal strings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this example:

  x = &quot;foo&quot;#
  y = &quot;foo&quot;#
  ...x...y...x...y....

We would normally turn this into:

  x = &quot;foo&quot;#
  y = x
  ...x...x...x...x....

But this breaks an invariant of Core, namely that the RHS of a top-level binding
of type Addr# must be a string literal, not another variable. See Note
[Core top-level string literals] in GHC.Core.

For this reason, we special case top-level bindings to literal strings and leave
the original RHS unmodified. This produces:

  x = &quot;foo&quot;#
  y = &quot;foo&quot;#
  ...x...x...x...x....

Now 'y' will be discarded as dead code, and we are done.

The net effect is that for the y-binding we want to
  - Use SUBSTITUTE, by extending the substitution with  y :-&gt; x
  - but leave the original binding for y undisturbed

This is done by cse_bind.  I got it wrong the first time (#13367).

Note [Delay inlining after CSE]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose (#15445) we have
   f,g :: Num a =&gt; a -&gt; a
   f x = ...f (x-1).....
   g y = ...g (y-1) ....

and we make some specialisations of 'g', either automatically, or via
a SPECIALISE pragma.  Then CSE kicks in and notices that the RHSs of
'f' and 'g' are identical, so we get
   f x = ...f (x-1)...
   g = f
   {-# RULES g @Int _ = $sg #-}

Now there is terrible danger that, in an importing module, we'll inline
'g' before we have a chance to run its specialisation!

Solution: during CSE, after a &quot;hit&quot; in the CSE cache
  * when adding a binding
        g = f
  * for a top-level function g
  * and g has specialisation RULES
add a NOINLINE[2] activation to it, to ensure it's not inlined
right away.

Notes:
* Why top level only?  Because for nested bindings we are already past
  phase 2 and will never return there.

* Why &quot;only if g has RULES&quot;?  Because there is no point in
  doing this if there are no RULES; and other things being
  equal it delays optimisation to delay inlining (#17409)


---- Historical note ---

This patch is simpler and more direct than an earlier
version:

  commit 2110738b280543698407924a16ac92b6d804dc36
  Author: Simon Peyton Jones &lt;simonpj@microsoft.com&gt;
  Date:   Mon Jul 30 13:43:56 2018 +0100

  Don't inline functions with RULES too early

We had to revert this patch because it made GHC itself slower.

Why? It delayed inlining of /all/ functions with RULES, and that was
very bad in GHC.Tc.Solver.Flatten.flatten_ty_con_app

* It delayed inlining of liftM
* That delayed the unravelling of the recursion in some dictionary
  bindings.
* That delayed some eta expansion, leaving
     flatten_ty_con_app = \x y. let &lt;stuff&gt; in \z. blah
* That allowed the float-out pass to put sguff between
  the \y and \z.
* And that permanently stopped eta expansion of the function,
  even once &lt;stuff&gt; was simplified.

-}</span><span>
</span><span id="line-550"></span><span>
</span><span id="line-551"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-type">tryForCSE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-552"></span><span id="tryForCSE"><span class="annot"><span class="annottext">tryForCSE :: CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var hs-var">tryForCSE</span></a></span></span><span> </span><span id="local-6989586621680961094"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961094"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680961093"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961093"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool, Expr CoreBndr) -&gt; Expr CoreBndr
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; (Bool, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#try_for_cse"><span class="hs-identifier hs-var">try_for_cse</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961094"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961093"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-553"></span><span>
</span><span id="line-554"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#try_for_cse"><span class="hs-identifier hs-type">try_for_cse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-555"></span><span class="hs-comment">-- (False, e') =&gt; We did not CSE the entire expression,</span><span>
</span><span id="line-556"></span><span class="hs-comment">--                but we might have CSE'd some sub-expressions,</span><span>
</span><span id="line-557"></span><span class="hs-comment">--                yielding e'</span><span>
</span><span id="line-558"></span><span class="hs-comment">--</span><span>
</span><span id="line-559"></span><span class="hs-comment">-- (True, te') =&gt; We CSE'd the entire expression,</span><span>
</span><span id="line-560"></span><span class="hs-comment">--                yielding the trivial expression te'</span><span>
</span><span id="line-561"></span><span id="try_for_cse"><span class="annot"><span class="annottext">try_for_cse :: CSEnv -&gt; Expr CoreBndr -&gt; (Bool, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#try_for_cse"><span class="hs-identifier hs-var hs-var">try_for_cse</span></a></span></span><span> </span><span id="local-6989586621680961092"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961092"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680961091"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961091"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-562"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680961090"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961090"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#lookupCSEnv"><span class="hs-identifier hs-var">lookupCSEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961092"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961088"><span class="hs-identifier hs-var">expr''</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">[Tickish CoreBndr] -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Utils.html#mkTicks"><span class="hs-identifier hs-var">mkTicks</span></a></span><span> </span><span class="annot"><span class="annottext">[Tickish CoreBndr]
</span><a href="#local-6989586621680961087"><span class="hs-identifier hs-var">ticks</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961090"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-563"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961086"><span class="hs-identifier hs-var">expr'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-564"></span><span>    </span><span class="hs-comment">-- The varToCoreExpr is needed if we have</span><span>
</span><span id="line-565"></span><span>    </span><span class="hs-comment">--   case e of xco { ...case e of yco { ... } ... }</span><span>
</span><span id="line-566"></span><span>    </span><span class="hs-comment">-- Then CSE will substitute yco -&gt; xco;</span><span>
</span><span id="line-567"></span><span>    </span><span class="hs-comment">-- but these are /coercion/ variables</span><span>
</span><span id="line-568"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-569"></span><span>    </span><span id="local-6989586621680961086"><span class="annot"><span class="annottext">expr' :: Expr CoreBndr
</span><a href="#local-6989586621680961086"><span class="hs-identifier hs-var hs-var">expr'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961092"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961091"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-570"></span><span>    </span><span id="local-6989586621680961088"><span class="annot"><span class="annottext">expr'' :: Expr CoreBndr
</span><a href="#local-6989586621680961088"><span class="hs-identifier hs-var hs-var">expr''</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool) -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. (Tickish CoreBndr -&gt; Bool) -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.Utils.html#stripTicksE"><span class="hs-identifier hs-var">stripTicksE</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961086"><span class="hs-identifier hs-var">expr'</span></a></span><span>
</span><span id="line-571"></span><span>    </span><span id="local-6989586621680961087"><span class="annot"><span class="annottext">ticks :: [Tickish CoreBndr]
</span><a href="#local-6989586621680961087"><span class="hs-identifier hs-var hs-var">ticks</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool) -&gt; Expr CoreBndr -&gt; [Tickish CoreBndr]
forall b.
(Tickish CoreBndr -&gt; Bool) -&gt; Expr b -&gt; [Tickish CoreBndr]
</span><a href="GHC.Core.Utils.html#stripTicksT"><span class="hs-identifier hs-var">stripTicksT</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961086"><span class="hs-identifier hs-var">expr'</span></a></span><span>
</span><span id="line-572"></span><span>    </span><span class="hs-comment">-- We don't want to lose the source notes when a common sub</span><span>
</span><span id="line-573"></span><span>    </span><span class="hs-comment">-- expression gets eliminated. Hence we push all (!) of them on</span><span>
</span><span id="line-574"></span><span>    </span><span class="hs-comment">-- top of the replaced sub-expression. This is probably not too</span><span>
</span><span id="line-575"></span><span>    </span><span class="hs-comment">-- useful in practice, but upholds our semantics.</span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span class="hs-comment">-- | Runs CSE on a single expression.</span><span>
</span><span id="line-578"></span><span class="hs-comment">--</span><span>
</span><span id="line-579"></span><span class="hs-comment">-- This entry point is not used in the compiler itself, but is provided</span><span>
</span><span id="line-580"></span><span class="hs-comment">-- as a convenient entry point for users of the GHC API.</span><span>
</span><span id="line-581"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseOneExpr"><span class="hs-identifier hs-type">cseOneExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-582"></span><span id="cseOneExpr"><span class="annot"><span class="annottext">cseOneExpr :: Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseOneExpr"><span class="hs-identifier hs-var hs-var">cseOneExpr</span></a></span></span><span> </span><span id="local-6989586621680961085"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961085"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961084"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961085"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-583"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680961084"><span class="annot"><span class="annottext">env :: CSEnv
</span><a href="#local-6989586621680961084"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="GHC.Core.Opt.CSE.html#emptyCSEnv"><span class="hs-identifier hs-var">emptyCSEnv</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">cs_subst :: Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Subst
</span><a href="GHC.Core.Subst.html#mkEmptySubst"><span class="hs-identifier hs-var">mkEmptySubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier hs-var">exprFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961085"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-584"></span><span>
</span><span id="line-585"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-type">cseExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-586"></span><span id="cseExpr"><span class="annot"><span class="annottext">cseExpr :: CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var hs-var">cseExpr</span></a></span></span><span> </span><span id="local-6989586621680961081"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961081"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680961079"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961079"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Expr CoreBndr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-var">csEnvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961081"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961079"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-587"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961076"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961076"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680961074"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680961074"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Expr CoreBndr
forall b. Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-var">csEnvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961076"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680961074"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-588"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span id="local-6989586621680961071"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680961071"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; Expr CoreBndr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680961071"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-589"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961070"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961070"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680961069"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961069"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#lookupSubst"><span class="hs-identifier hs-var">lookupSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961070"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961069"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-590"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961067"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961067"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680961065"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961065"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680961064"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961064"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961067"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961065"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var">tryForCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961067"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961064"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-591"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961063"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961063"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680961061"><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680961061"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680961060"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961060"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. Tickish CoreBndr -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680961061"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961063"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961060"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-592"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961059"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961059"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680961057"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961057"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680961056"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680961056"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Coercion -&gt; Expr CoreBndr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var">tryForCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961059"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961057"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; Coercion -&gt; Coercion
Subst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-var">csEnvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961059"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680961056"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-593"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961055"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961055"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680961053"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961053"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680961052"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961052"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961051"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961051"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961050"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961050"><span class="hs-identifier hs-var">b'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinder"><span class="hs-identifier hs-var">addBinder</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961055"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961053"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-594"></span><span>                                    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961050"><span class="hs-identifier hs-var">b'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961051"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961052"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-595"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961049"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961049"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680961047"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680961047"><span class="hs-identifier hs-var">bind</span></a></span></span><span> </span><span id="local-6989586621680961046"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961046"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961045"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961045"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961044"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680961044"><span class="hs-identifier hs-var">bind'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; CSEnv -&gt; CoreBind -&gt; (CSEnv, CoreBind)
</span><a href="GHC.Core.Opt.CSE.html#cseBind"><span class="hs-identifier hs-var">cseBind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961049"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680961047"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-596"></span><span>                                    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621680961044"><span class="hs-identifier hs-var">bind'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961045"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961046"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-597"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseExpr"><span class="hs-identifier hs-var">cseExpr</span></a></span><span> </span><span id="local-6989586621680961042"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961042"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680961040"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961040"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680961039"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961039"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680961038"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961038"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680961037"><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961037"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv
-&gt; Expr CoreBndr -&gt; CoreBndr -&gt; Type -&gt; [OutAlt] -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseCase"><span class="hs-identifier hs-var">cseCase</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961042"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961040"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961039"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961038"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961037"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-598"></span><span>
</span><span id="line-599"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#cseCase"><span class="hs-identifier hs-type">cseCase</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InExpr"><span class="hs-identifier hs-type">InExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#InType"><span class="hs-identifier hs-type">InType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#InAlt"><span class="hs-identifier hs-type">InAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-600"></span><span id="cseCase"><span class="annot"><span class="annottext">cseCase :: CSEnv
-&gt; Expr CoreBndr -&gt; CoreBndr -&gt; Type -&gt; [OutAlt] -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#cseCase"><span class="hs-identifier hs-var hs-var">cseCase</span></a></span></span><span> </span><span id="local-6989586621680961033"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961033"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680961032"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961032"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680961031"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961031"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680961030"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961030"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680961029"><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961029"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-601"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; CoreBndr -&gt; Type -&gt; [OutAlt] -&gt; Expr CoreBndr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961028"><span class="hs-identifier hs-var">scrut1</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961027"><span class="hs-identifier hs-var">bndr3</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961026"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">([OutAlt] -&gt; Expr CoreBndr) -&gt; [OutAlt] -&gt; Expr CoreBndr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-602"></span><span>    </span><span class="annot"><span class="annottext">CSEnv -&gt; [OutAlt] -&gt; [OutAlt]
</span><a href="GHC.Core.Opt.CSE.html#combineAlts"><span class="hs-identifier hs-var">combineAlts</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961024"><span class="hs-identifier hs-var">alt_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OutAlt -&gt; OutAlt) -&gt; [OutAlt] -&gt; [OutAlt]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">OutAlt -&gt; OutAlt
</span><a href="#local-6989586621680961023"><span class="hs-identifier hs-var">cse_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961029"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-603"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-604"></span><span>    </span><span id="local-6989586621680961026"><span class="annot"><span class="annottext">ty' :: Type
</span><a href="#local-6989586621680961026"><span class="hs-identifier hs-var hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-var">csEnvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961033"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680961030"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-605"></span><span>    </span><span id="local-6989586621680961028"><span class="annot"><span class="annottext">scrut1 :: Expr CoreBndr
</span><a href="#local-6989586621680961028"><span class="hs-identifier hs-var hs-var">scrut1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var">tryForCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961033"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961032"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-606"></span><span>
</span><span id="line-607"></span><span>    </span><span id="local-6989586621680961022"><span class="annot"><span class="annottext">bndr1 :: CoreBndr
</span><a href="#local-6989586621680961022"><span class="hs-identifier hs-var hs-var">bndr1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#zapIdOccInfo"><span class="hs-identifier hs-var">zapIdOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961031"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-608"></span><span>      </span><span class="hs-comment">-- Zapping the OccInfo is needed because the extendCSEnv</span><span>
</span><span id="line-609"></span><span>      </span><span class="hs-comment">-- in cse_alt may mean that a dead case binder</span><span>
</span><span id="line-610"></span><span>      </span><span class="hs-comment">-- becomes alive, and Lint rejects that</span><span>
</span><span id="line-611"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961021"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961021"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961020"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961020"><span class="hs-identifier hs-var">bndr2</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinder"><span class="hs-identifier hs-var">addBinder</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961033"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961022"><span class="hs-identifier hs-var">bndr1</span></a></span><span>
</span><span id="line-612"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680961024"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961024"><span class="hs-identifier hs-var">alt_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961027"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961027"><span class="hs-identifier hs-var">bndr3</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinding"><span class="hs-identifier hs-var">addBinding</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961021"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961031"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961020"><span class="hs-identifier hs-var">bndr2</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961028"><span class="hs-identifier hs-var">scrut1</span></a></span><span>
</span><span id="line-613"></span><span>         </span><span class="hs-comment">-- addBinding: see Note [CSE for case expressions]</span><span>
</span><span id="line-614"></span><span>
</span><span id="line-615"></span><span>    </span><span class="annot"><a href="#local-6989586621680961019"><span class="hs-identifier hs-type">con_target</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-616"></span><span>    </span><span id="local-6989586621680961019"><span class="annot"><span class="annottext">con_target :: Expr CoreBndr
</span><a href="#local-6989586621680961019"><span class="hs-identifier hs-var hs-var">con_target</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#lookupSubst"><span class="hs-identifier hs-var">lookupSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961024"><span class="hs-identifier hs-var">alt_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961031"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-617"></span><span>
</span><span id="line-618"></span><span>    </span><span class="annot"><a href="#local-6989586621680961018"><span class="hs-identifier hs-type">arg_tys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutType"><span class="hs-identifier hs-type">OutType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-619"></span><span>    </span><span id="local-6989586621680961018"><span class="annot"><span class="annottext">arg_tys :: [Type]
</span><a href="#local-6989586621680961018"><span class="hs-identifier hs-var hs-var">arg_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type]
</span><a href="GHC.Core.Type.html#tyConAppArgs"><span class="hs-identifier hs-var">tyConAppArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680961027"><span class="hs-identifier hs-var">bndr3</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-620"></span><span>
</span><span id="line-621"></span><span>    </span><span class="hs-comment">-- See Note [CSE for case alternatives]</span><span>
</span><span id="line-622"></span><span>    </span><span id="local-6989586621680961023"><span class="annot"><span class="annottext">cse_alt :: OutAlt -&gt; OutAlt
</span><a href="#local-6989586621680961023"><span class="hs-identifier hs-var hs-var">cse_alt</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-type">DataAlt</span></a></span><span> </span><span id="local-6989586621680961015"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680961015"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961014"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961014"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961013"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961013"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-623"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680961015"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961012"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var">tryForCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961011"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961013"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-624"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-625"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680961010"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961010"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961012"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961012"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addBinders"><span class="hs-identifier hs-var">addBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961024"><span class="hs-identifier hs-var">alt_env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961014"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-626"></span><span>          </span><span id="local-6989586621680961011"><span class="annot"><span class="annottext">new_env :: CSEnv
</span><a href="#local-6989586621680961011"><span class="hs-identifier hs-var hs-var">new_env</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSEnv"><span class="hs-identifier hs-var">extendCSEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961010"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961009"><span class="hs-identifier hs-var">con_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961019"><span class="hs-identifier hs-var">con_target</span></a></span><span>
</span><span id="line-627"></span><span>          </span><span id="local-6989586621680961009"><span class="annot"><span class="annottext">con_expr :: Expr CoreBndr
</span><a href="#local-6989586621680961009"><span class="hs-identifier hs-var hs-var">con_expr</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AltCon -&gt; [CoreBndr] -&gt; [Type] -&gt; Expr CoreBndr
</span><a href="GHC.Core.Utils.html#mkAltExpr"><span class="hs-identifier hs-var">mkAltExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680961015"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961012"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680961018"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-628"></span><span>
</span><span id="line-629"></span><span>    </span><span class="annot"><a href="#local-6989586621680961023"><span class="hs-identifier hs-var">cse_alt</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680961008"><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680961008"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961007"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961007"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961006"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961006"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-630"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680961008"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961005"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#tryForCSE"><span class="hs-identifier hs-var">tryForCSE</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961004"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680961006"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-631"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-632"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680961004"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961004"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961005"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961005"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addBinders"><span class="hs-identifier hs-var">addBinders</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961024"><span class="hs-identifier hs-var">alt_env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680961007"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-633"></span><span>
</span><span id="line-634"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#combineAlts"><span class="hs-identifier hs-type">combineAlts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutAlt"><span class="hs-identifier hs-type">OutAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#OutAlt"><span class="hs-identifier hs-type">OutAlt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-635"></span><span class="hs-comment">-- See Note [Combine case alternatives]</span><span>
</span><span id="line-636"></span><span id="combineAlts"><span class="annot"><span class="annottext">combineAlts :: CSEnv -&gt; [OutAlt] -&gt; [OutAlt]
</span><a href="GHC.Core.Opt.CSE.html#combineAlts"><span class="hs-identifier hs-var hs-var">combineAlts</span></a></span></span><span> </span><span id="local-6989586621680961003"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961003"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680961002"><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961002"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-637"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680961001"><span class="annot"><span class="annottext">OutAlt
</span><a href="#local-6989586621680961001"><span class="hs-identifier hs-var">alt1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680961000"><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961000"><span class="hs-identifier hs-var">rest_alts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[OutAlt] -&gt; (Maybe OutAlt, [OutAlt])
</span><a href="#local-6989586621680960999"><span class="hs-identifier hs-var">find_bndr_free_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961002"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-638"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680960998"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960998"><span class="hs-identifier hs-var">bndrs1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680960997"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960997"><span class="hs-identifier hs-var">rhs1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OutAlt
</span><a href="#local-6989586621680961001"><span class="hs-identifier hs-var">alt1</span></a></span><span>
</span><span id="line-639"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680960996"><span class="annot"><span class="annottext">filtered_alts :: [OutAlt]
</span><a href="#local-6989586621680960996"><span class="hs-identifier hs-var hs-var">filtered_alts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutAlt -&gt; Bool) -&gt; [OutAlt] -&gt; [OutAlt]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; OutAlt -&gt; Bool
forall {a} {b}. Expr CoreBndr -&gt; (a, b, Expr CoreBndr) -&gt; Bool
</span><a href="#local-6989586621680960995"><span class="hs-identifier hs-var">identical_alt</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960997"><span class="hs-identifier hs-var">rhs1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961000"><span class="hs-identifier hs-var">rest_alts</span></a></span><span>
</span><span id="line-640"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OutAlt] -&gt; [OutAlt] -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-identifier hs-var">equalLength</span></a></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961000"><span class="hs-identifier hs-var">rest_alts</span></a></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960996"><span class="hs-identifier hs-var">filtered_alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-641"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">bndrs1</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">alts</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-642"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960997"><span class="hs-identifier hs-var">rhs1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutAlt -&gt; [OutAlt] -&gt; [OutAlt]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960996"><span class="hs-identifier hs-var">filtered_alts</span></a></span><span>
</span><span id="line-643"></span><span>
</span><span id="line-644"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-645"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680961002"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-646"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-647"></span><span>    </span><span id="local-6989586621680960990"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680960990"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; InScopeSet
</span><a href="GHC.Core.Subst.html#substInScope"><span class="hs-identifier hs-var">substInScope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-var">csEnvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680961003"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-648"></span><span>
</span><span id="line-649"></span><span>    </span><span class="annot"><a href="#local-6989586621680960999"><span class="hs-identifier hs-type">find_bndr_free_alt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreAlt"><span class="hs-identifier hs-type">CoreAlt</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-650"></span><span>       </span><span class="hs-comment">-- The (Just alt) is a binder-free alt</span><span>
</span><span id="line-651"></span><span>       </span><span class="hs-comment">-- See Note [Combine case alts: awkward corner]</span><span>
</span><span id="line-652"></span><span>    </span><span id="local-6989586621680960999"><span class="annot"><span class="annottext">find_bndr_free_alt :: [OutAlt] -&gt; (Maybe OutAlt, [OutAlt])
</span><a href="#local-6989586621680960999"><span class="hs-identifier hs-var hs-var">find_bndr_free_alt</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-653"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe OutAlt
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-654"></span><span>    </span><span class="annot"><a href="#local-6989586621680960999"><span class="hs-identifier hs-var">find_bndr_free_alt</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680960987"><span class="annot"><span class="annottext">alt :: OutAlt
</span><a href="#local-6989586621680960987"><span class="hs-identifier hs-var">alt</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680960986"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960986"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Expr CoreBndr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680960985"><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960985"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-655"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960986"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutAlt -&gt; Maybe OutAlt
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">OutAlt
</span><a href="#local-6989586621680960987"><span class="hs-identifier hs-var">alt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960985"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-656"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[OutAlt] -&gt; (Maybe OutAlt, [OutAlt])
</span><a href="#local-6989586621680960999"><span class="hs-identifier hs-var">find_bndr_free_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960985"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-657"></span><span>                       </span><span class="hs-special">(</span><span id="local-6989586621680960984"><span class="annot"><span class="annottext">Maybe OutAlt
</span><a href="#local-6989586621680960984"><span class="hs-identifier hs-var">mb_bf</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680960983"><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960983"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe OutAlt
</span><a href="#local-6989586621680960984"><span class="hs-identifier hs-var">mb_bf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">OutAlt
</span><a href="#local-6989586621680960987"><span class="hs-identifier hs-var">alt</span></a></span><span class="annot"><span class="annottext">OutAlt -&gt; [OutAlt] -&gt; [OutAlt]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[OutAlt]
</span><a href="#local-6989586621680960983"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-658"></span><span>
</span><span id="line-659"></span><span>    </span><span id="local-6989586621680960995"><span class="annot"><span class="annottext">identical_alt :: Expr CoreBndr -&gt; (a, b, Expr CoreBndr) -&gt; Bool
</span><a href="#local-6989586621680960995"><span class="hs-identifier hs-var hs-var">identical_alt</span></a></span></span><span> </span><span id="local-6989586621680960982"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960982"><span class="hs-identifier hs-var">rhs1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680960981"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960981"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Utils.html#eqExpr"><span class="hs-identifier hs-var">eqExpr</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680960990"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960982"><span class="hs-identifier hs-var">rhs1</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960981"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-660"></span><span>       </span><span class="hs-comment">-- Even if this alt has binders, they will have been cloned</span><span>
</span><span id="line-661"></span><span>       </span><span class="hs-comment">-- If any of these binders are mentioned in 'rhs', then</span><span>
</span><span id="line-662"></span><span>       </span><span class="hs-comment">-- 'rhs' won't compare equal to 'rhs1' (which is from an</span><span>
</span><span id="line-663"></span><span>       </span><span class="hs-comment">-- alt with no binders).</span><span>
</span><span id="line-664"></span><span>
</span><span id="line-665"></span><span class="hs-comment">{- Note [CSE for case alternatives]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider   case e of x
            K1 y -&gt; ....(K1 y)...
            K2   -&gt; ....K2....

We definitely want to CSE that (K1 y) into just x.

But what about the lone K2?  At first you would think &quot;no&quot; because
turning K2 into 'x' increases the number of live variables.  But

* Turning K2 into x increases the chance of combining identical alts.
  Example      case xs of
                  (_:_) -&gt; f xs
                  []    -&gt; f []
  See #17901 and simplCore/should_compile/T17901 for more examples
  of this kind.

* The next run of the simplifier will turn 'x' back into K2, so we won't
  permanently bloat the free-var count.


Note [Combine case alternatives]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combineAlts is just a more heavyweight version of the use of
combineIdenticalAlts in GHC.Core.Opt.Simplify.Utils.prepareAlts.  The basic idea is
to transform

    DEFAULT -&gt; e1
    K x     -&gt; e1
    W y z   -&gt; e2
===&gt;
   DEFAULT -&gt; e1
   W y z   -&gt; e2

In the simplifier we use cheapEqExpr, because it is called a lot.
But here in CSE we use the full eqExpr.  After all, two alternatives usually
differ near the root, so it probably isn't expensive to compare the full
alternative.  It seems like the same kind of thing that CSE is supposed
to be doing, which is why I put it here.

I actually saw some examples in the wild, where some inlining made e1 too
big for cheapEqExpr to catch it.

Note [Combine case alts: awkward corner]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We would really like to check isDeadBinder on the binders in the
alternative.  But alas, the simplifer zaps occ-info on binders in case
alternatives; see Note [Case alternative occ info] in GHC.Core.Opt.Simplify.

* One alternative (perhaps a good one) would be to do OccAnal
  just before CSE.  Then perhaps we could get rid of combineIdenticalAlts
  in the Simplifier, which might save work.

* Another would be for CSE to return free vars as it goes.

* But the current solution is to find a nullary alternative (including
  the DEFAULT alt, if any). This will not catch
      case x of
        A y   -&gt; blah
        B z p -&gt; blah
  where no alternative is nullary or DEFAULT.  But the current
  solution is at least cheap.


************************************************************************
*                                                                      *
\section{The CSE envt}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-736"></span><span>
</span><span id="line-737"></span><span class="hs-keyword">data</span><span> </span><span id="CSEnv"><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-var">CSEnv</span></a></span></span><span>
</span><span id="line-738"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="CS"><span class="annot"><a href="GHC.Core.Opt.CSE.html#CS"><span class="hs-identifier hs-var">CS</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="cs_subst"><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var hs-var">cs_subst</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>  </span><span class="hs-comment">-- Maps InBndrs to OutExprs</span><span>
</span><span id="line-739"></span><span>            </span><span class="hs-comment">-- The substitution variables to</span><span>
</span><span id="line-740"></span><span>            </span><span class="hs-comment">-- /trivial/ OutExprs, not arbitrary expressions</span><span>
</span><span id="line-741"></span><span>
</span><span id="line-742"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="cs_map"><span class="annot"><span class="annottext">CSEnv -&gt; CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_map"><span class="hs-identifier hs-var hs-var">cs_map</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Map.html#CoreMap"><span class="hs-identifier hs-type">CoreMap</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>   </span><span class="hs-comment">-- The reverse mapping</span><span>
</span><span id="line-743"></span><span>            </span><span class="hs-comment">-- Maps a OutExpr to a /trivial/ OutExpr</span><span>
</span><span id="line-744"></span><span>            </span><span class="hs-comment">-- The key of cs_map is stripped of all Ticks</span><span>
</span><span id="line-745"></span><span>
</span><span id="line-746"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="cs_rec_map"><span class="annot"><span class="annottext">CSEnv -&gt; CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_rec_map"><span class="hs-identifier hs-var hs-var">cs_rec_map</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Map.html#CoreMap"><span class="hs-identifier hs-type">CoreMap</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-747"></span><span>            </span><span class="hs-comment">-- See Note [CSE for recursive bindings]</span><span>
</span><span id="line-748"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-749"></span><span>
</span><span id="line-750"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#emptyCSEnv"><span class="hs-identifier hs-type">emptyCSEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span>
</span><span id="line-751"></span><span id="emptyCSEnv"><span class="annot"><span class="annottext">emptyCSEnv :: CSEnv
</span><a href="GHC.Core.Opt.CSE.html#emptyCSEnv"><span class="hs-identifier hs-var hs-var">emptyCSEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CS :: Subst
-&gt; CoreMap (Expr CoreBndr) -&gt; CoreMap (Expr CoreBndr) -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#CS"><span class="hs-identifier hs-type">CS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_map :: CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_map"><span class="hs-identifier hs-var">cs_map</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
forall a. CoreMap a
</span><a href="GHC.Core.Map.html#emptyCoreMap"><span class="hs-identifier hs-var">emptyCoreMap</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cs_rec_map :: CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_rec_map"><span class="hs-identifier hs-var">cs_rec_map</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
forall a. CoreMap a
</span><a href="GHC.Core.Map.html#emptyCoreMap"><span class="hs-identifier hs-var">emptyCoreMap</span></a></span><span>
</span><span id="line-752"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cs_subst :: Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="GHC.Core.Subst.html#emptySubst"><span class="hs-identifier hs-var">emptySubst</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-753"></span><span>
</span><span id="line-754"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#lookupCSEnv"><span class="hs-identifier hs-type">lookupCSEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-755"></span><span id="lookupCSEnv"><span class="annot"><span class="annottext">lookupCSEnv :: CSEnv -&gt; Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#lookupCSEnv"><span class="hs-identifier hs-var hs-var">lookupCSEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CS"><span class="hs-identifier hs-type">CS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_map :: CSEnv -&gt; CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_map"><span class="hs-identifier hs-var">cs_map</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680960975"><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
</span><a href="#local-6989586621680960975"><span class="hs-identifier hs-var">csmap</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680960974"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960974"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-756"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr) -&gt; Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
forall a. CoreMap a -&gt; Expr CoreBndr -&gt; Maybe a
</span><a href="GHC.Core.Map.html#lookupCoreMap"><span class="hs-identifier hs-var">lookupCoreMap</span></a></span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
</span><a href="#local-6989586621680960975"><span class="hs-identifier hs-var">csmap</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960974"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#extendCSEnv"><span class="hs-identifier hs-type">extendCSEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span>
</span><span id="line-759"></span><span id="extendCSEnv"><span class="annot"><span class="annottext">extendCSEnv :: CSEnv -&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSEnv"><span class="hs-identifier hs-var hs-var">extendCSEnv</span></a></span></span><span> </span><span id="local-6989586621680960972"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960972"><span class="hs-identifier hs-var">cse</span></a></span></span><span> </span><span id="local-6989586621680960971"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960971"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621680960970"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960970"><span class="hs-identifier hs-var">triv_expr</span></a></span></span><span>
</span><span id="line-760"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960972"><span class="hs-identifier hs-var">cse</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_map :: CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_map"><span class="hs-identifier hs-var">cs_map</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
-&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CoreMap (Expr CoreBndr)
forall a. CoreMap a -&gt; Expr CoreBndr -&gt; a -&gt; CoreMap a
</span><a href="GHC.Core.Map.html#extendCoreMap"><span class="hs-identifier hs-var">extendCoreMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_map"><span class="hs-identifier hs-var hs-var">cs_map</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960972"><span class="hs-identifier hs-var">cse</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960968"><span class="hs-identifier hs-var">sexpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960970"><span class="hs-identifier hs-var">triv_expr</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-761"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-762"></span><span>    </span><span id="local-6989586621680960968"><span class="annot"><span class="annottext">sexpr :: Expr CoreBndr
</span><a href="#local-6989586621680960968"><span class="hs-identifier hs-var hs-var">sexpr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish CoreBndr -&gt; Bool) -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. (Tickish CoreBndr -&gt; Bool) -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.Utils.html#stripTicksE"><span class="hs-identifier hs-var">stripTicksE</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960971"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-763"></span><span>
</span><span id="line-764"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#extendCSRecEnv"><span class="hs-identifier hs-type">extendCSRecEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span>
</span><span id="line-765"></span><span class="hs-comment">-- See Note [CSE for recursive bindings]</span><span>
</span><span id="line-766"></span><span id="extendCSRecEnv"><span class="annot"><span class="annottext">extendCSRecEnv :: CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSRecEnv"><span class="hs-identifier hs-var hs-var">extendCSRecEnv</span></a></span></span><span> </span><span id="local-6989586621680960967"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960967"><span class="hs-identifier hs-var">cse</span></a></span></span><span> </span><span id="local-6989586621680960966"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960966"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680960965"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960965"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621680960964"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960964"><span class="hs-identifier hs-var">triv_expr</span></a></span></span><span>
</span><span id="line-767"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960967"><span class="hs-identifier hs-var">cse</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_rec_map :: CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_rec_map"><span class="hs-identifier hs-var">cs_rec_map</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
-&gt; Expr CoreBndr -&gt; Expr CoreBndr -&gt; CoreMap (Expr CoreBndr)
forall a. CoreMap a -&gt; Expr CoreBndr -&gt; a -&gt; CoreMap a
</span><a href="GHC.Core.Map.html#extendCoreMap"><span class="hs-identifier hs-var">extendCoreMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_rec_map"><span class="hs-identifier hs-var hs-var">cs_rec_map</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960967"><span class="hs-identifier hs-var">cse</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960966"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960965"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960964"><span class="hs-identifier hs-var">triv_expr</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-768"></span><span>
</span><span id="line-769"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#lookupCSRecEnv"><span class="hs-identifier hs-type">lookupCSRecEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-770"></span><span class="hs-comment">-- See Note [CSE for recursive bindings]</span><span>
</span><span id="line-771"></span><span id="lookupCSRecEnv"><span class="annot"><span class="annottext">lookupCSRecEnv :: CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#lookupCSRecEnv"><span class="hs-identifier hs-var hs-var">lookupCSRecEnv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CS"><span class="hs-identifier hs-type">CS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_rec_map :: CSEnv -&gt; CoreMap (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#cs_rec_map"><span class="hs-identifier hs-var">cs_rec_map</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680960963"><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
</span><a href="#local-6989586621680960963"><span class="hs-identifier hs-var">csmap</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680960962"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960962"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680960961"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960961"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-772"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr) -&gt; Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
forall a. CoreMap a -&gt; Expr CoreBndr -&gt; Maybe a
</span><a href="GHC.Core.Map.html#lookupCoreMap"><span class="hs-identifier hs-var">lookupCoreMap</span></a></span><span> </span><span class="annot"><span class="annottext">CoreMap (Expr CoreBndr)
</span><a href="#local-6989586621680960963"><span class="hs-identifier hs-var">csmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960962"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960961"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-773"></span><span>
</span><span id="line-774"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-type">csEnvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span>
</span><span id="line-775"></span><span id="csEnvSubst"><span class="annot"><span class="annottext">csEnvSubst :: CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#csEnvSubst"><span class="hs-identifier hs-var hs-var">csEnvSubst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var hs-var">cs_subst</span></a></span><span>
</span><span id="line-776"></span><span>
</span><span id="line-777"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#lookupSubst"><span class="hs-identifier hs-type">lookupSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#OutExpr"><span class="hs-identifier hs-type">OutExpr</span></a></span><span>
</span><span id="line-778"></span><span id="lookupSubst"><span class="annot"><span class="annottext">lookupSubst :: CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Opt.CSE.html#lookupSubst"><span class="hs-identifier hs-var hs-var">lookupSubst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CS"><span class="hs-identifier hs-type">CS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_subst :: CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680960960"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960960"><span class="hs-identifier hs-var">sub</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680960959"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960959"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreBndr -&gt; Expr CoreBndr
Subst -&gt; CoreBndr -&gt; Expr CoreBndr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">lookupIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960960"><span class="hs-identifier hs-var">sub</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960959"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-779"></span><span>
</span><span id="line-780"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#extendCSSubst"><span class="hs-identifier hs-type">extendCSSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span>
</span><span id="line-781"></span><span id="extendCSSubst"><span class="annot"><span class="annottext">extendCSSubst :: CSEnv -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; CSEnv
</span><a href="GHC.Core.Opt.CSE.html#extendCSSubst"><span class="hs-identifier hs-var hs-var">extendCSSubst</span></a></span></span><span> </span><span id="local-6989586621680960956"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960956"><span class="hs-identifier hs-var">cse</span></a></span></span><span> </span><span id="local-6989586621680960955"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960955"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621680960954"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960954"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960956"><span class="hs-identifier hs-var">cse</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_subst :: Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; CoreBndr -&gt; Expr CoreBndr -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubst"><span class="hs-identifier hs-var">extendSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var hs-var">cs_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960956"><span class="hs-identifier hs-var">cse</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960955"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680960954"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-782"></span><span>
</span><span id="line-783"></span><span class="hs-comment">-- | Add clones to the substitution to deal with shadowing.  See</span><span>
</span><span id="line-784"></span><span class="hs-comment">-- Note [Shadowing] for more details.  You should call this whenever</span><span>
</span><span id="line-785"></span><span class="hs-comment">-- you go under a binder.</span><span>
</span><span id="line-786"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#addBinder"><span class="hs-identifier hs-type">addBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span id="addBinder"><span class="annot"><span class="annottext">addBinder :: CSEnv -&gt; CoreBndr -&gt; (CSEnv, CoreBndr)
</span><a href="GHC.Core.Opt.CSE.html#addBinder"><span class="hs-identifier hs-var hs-var">addBinder</span></a></span></span><span> </span><span id="local-6989586621680960952"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960952"><span class="hs-identifier hs-var">cse</span></a></span></span><span> </span><span id="local-6989586621680960951"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960951"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960952"><span class="hs-identifier hs-var">cse</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_subst :: Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960950"><span class="hs-identifier hs-var">sub'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960949"><span class="hs-identifier hs-var">v'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-788"></span><span>                </span><span class="hs-keyword">where</span><span>
</span><span id="line-789"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621680960950"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960950"><span class="hs-identifier hs-var">sub'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680960949"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960949"><span class="hs-identifier hs-var">v'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; CoreBndr -&gt; (Subst, CoreBndr)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var hs-var">cs_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960952"><span class="hs-identifier hs-var">cse</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680960951"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-790"></span><span>
</span><span id="line-791"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#addBinders"><span class="hs-identifier hs-type">addBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-792"></span><span id="addBinders"><span class="annot"><span class="annottext">addBinders :: CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addBinders"><span class="hs-identifier hs-var hs-var">addBinders</span></a></span></span><span> </span><span id="local-6989586621680960947"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960947"><span class="hs-identifier hs-var">cse</span></a></span></span><span> </span><span id="local-6989586621680960946"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960946"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960947"><span class="hs-identifier hs-var">cse</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_subst :: Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960945"><span class="hs-identifier hs-var">sub'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960944"><span class="hs-identifier hs-var">vs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-793"></span><span>                </span><span class="hs-keyword">where</span><span>
</span><span id="line-794"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621680960945"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960945"><span class="hs-identifier hs-var">sub'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680960944"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960944"><span class="hs-identifier hs-var">vs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [CoreBndr] -&gt; (Subst, [CoreBndr])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var hs-var">cs_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960947"><span class="hs-identifier hs-var">cse</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960946"><span class="hs-identifier hs-var">vs</span></a></span><span>
</span><span id="line-795"></span><span>
</span><span id="line-796"></span><span class="annot"><a href="GHC.Core.Opt.CSE.html#addRecBinders"><span class="hs-identifier hs-type">addRecBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CSE.html#CSEnv"><span class="hs-identifier hs-type">CSEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-797"></span><span id="addRecBinders"><span class="annot"><span class="annottext">addRecBinders :: CSEnv -&gt; [CoreBndr] -&gt; (CSEnv, [CoreBndr])
</span><a href="GHC.Core.Opt.CSE.html#addRecBinders"><span class="hs-identifier hs-var hs-var">addRecBinders</span></a></span></span><span> </span><span id="local-6989586621680960942"><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960942"><span class="hs-identifier hs-var">cse</span></a></span></span><span> </span><span id="local-6989586621680960941"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960941"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960942"><span class="hs-identifier hs-var">cse</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cs_subst :: Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var">cs_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960940"><span class="hs-identifier hs-var">sub'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960939"><span class="hs-identifier hs-var">vs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-798"></span><span>                </span><span class="hs-keyword">where</span><span>
</span><span id="line-799"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621680960940"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680960940"><span class="hs-identifier hs-var">sub'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680960939"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960939"><span class="hs-identifier hs-var">vs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [CoreBndr] -&gt; (Subst, [CoreBndr])
</span><a href="GHC.Core.Subst.html#substRecBndrs"><span class="hs-identifier hs-var">substRecBndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSEnv -&gt; Subst
</span><a href="GHC.Core.Opt.CSE.html#cs_subst"><span class="hs-identifier hs-var hs-var">cs_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CSEnv
</span><a href="#local-6989586621680960942"><span class="hs-identifier hs-var">cse</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680960941"><span class="hs-identifier hs-var">vs</span></a></span><span>
</span><span id="line-800"></span></pre></body></html>